package cn.itcast.travel.service.impl;

import cn.itcast.travel.domain.mood;
import cn.itcast.travel.service.MoodService;
import cn.itcast.travel.util.JDBCUtils;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;

import java.util.List;

public class MoodServiceImpl implements MoodService {
    private JdbcTemplate template = new JdbcTemplate(JDBCUtils.getDataSource());
    //获取心情日志
    @Override
    public List<mood> Getmood(String id) {
        List<mood> ms=null;
        String sql="select * from t_mood where bloggerid =? order by date desc";
        ms=template.query(sql,new BeanPropertyRowMapper<mood>(mood.class),id);
        return ms;
    }

    //添加心情
    @Override
    public void addmood(mood m) {
        String sql="insert into t_mood value(?,?,?)";
        template.update(sql,m.getContent(),m.getBloggerid(),m.getDate());
    }
}
